﻿add_namespace = SouthSudan
add_namespace = SouthSudanNews

### South Sudan civil war cleanup events ###

#Give the winner SSU cosmetic tag
country_event = {
	id = SouthSudan.0
	
	hidden = yes
	
	trigger = {
		OR = {
			AND = {
				tag = SSU
				NOT = {
					country_exists = AGF 
				}
			}
			AND = {
				tag = AGF
				NOT = {
					country_exists = SSU 
				}
			}
		}
		NOT = { has_global_flag = SouthSudan_Civil_War_Over }
	}
	
	mean_time_to_happen = {
		days = 2
	}
	
	immediate = {
		#Civil war is over
		set_global_flag = SouthSudan_Civil_War_Over
		#Clear core status (normal states
		225 = {
			remove_core_of = SSU
			remove_core_of = AGF
		}
		226 = {
			remove_core_of = SSU
			remove_core_of = AGF
		}
		227 = {
			remove_core_of = SSU
			remove_core_of = AGF
		}
		924 = {
			remove_core_of = SSU
			remove_core_of = AGF
		}
		#Make the winner Central African Republic
		if = {
			limit = {
				tag = AGF
			}
			set_cosmetic_tag = SSU
		}
		add_state_core = 225
		add_state_core = 226
		add_state_core = 227
		add_state_core = 924
		set_capital = 227
		
		#Special States
		##Kafia Kingi (held by Sudan, core of South Sudan)
		if = {
			limit = {
				923 = {
					OR = {
						is_core_of = SSU
						is_core_of = AGF
					}
				}
			}
			923 = {
				remove_core_of = SSU
				remove_core_of = AGF
			}
			add_state_core = 923
		}
		if = {
			limit = {
				923 = {
					OR = {
						is_claimed_by = SSU
						is_claimed_by = AGF
					}
				}
			}
			923 = {
				remove_claim_by = SSU
				remove_claim_by = AGF
			}
			add_state_claim = 923
		}
		##Ilemi (held by Kenya, core of South Sudan)
		if = {
			limit = {
				925 = {
					OR = {
						is_core_of = SSU
						is_core_of = AGF
					}
				}
			}
			925 = {
				remove_core_of = SSU
				remove_core_of = AGF
			}
			add_state_core = 925
		}
		if = {
			limit = {
				925 = {
					OR = {
						is_claimed_by = SSU
						is_claimed_by = AGF
					}
				}
			}
			925 = {
				remove_claim_by = SSU
				remove_claim_by = AGF
			}
			add_state_claim = 925
		}
		##Napak (held by Kenya, claimed by South Sudan)
		if = {
			limit = {
				926 = {
					OR = {
						is_core_of = SSU
						is_core_of = AGF
					}
				}
			}
			926 = {
				remove_core_of = SSU
				remove_core_of = AGF
			}
			add_state_core = 926
		}
		if = {
			limit = {
				926 = {
					OR = {
						is_claimed_by = SSU
						is_claimed_by = AGF
					}
				}
			}
			926 = {
				remove_claim_by = SSU
				remove_claim_by = AGF
			}
			add_state_claim = 926
		}
		#Abyei (held by Sudan, core of South Sudan)
		if = {
			limit = {
				927 = {
					OR = {
						is_core_of = SSU
						is_core_of = AGF
					}
				}
			}
			927 = {
				remove_core_of = SSU
				remove_core_of = AGF
			}
			add_state_core = 927
		}
		if = {
			limit = {
				927 = {
					OR = {
						is_claimed_by = SSU
						is_claimed_by = AGF
					}
				}
			}
			927 = {
				remove_claim_by = SSU
				remove_claim_by = AGF
			}
			add_state_claim = 927
		}
	}
	
	option = {
		name = SouthSudan.0.a
		hidden_effect = { news_event = { id = SouthSudanNews.1 hours = 6 } }
		log = "[GetDateText]: [This.GetName]: SouthSudan.0.a executed"
	}
}

#Recreate South Sudan in case it has been annexed
country_event = {
	id = SouthSudan.1
	
	hidden = yes
	
	trigger = {
		NOT = {
			country_exists = SSU
			country_exists = AGF
		}
		NOT = { 324 = { is_core_of = SSU } }
	}
	
	mean_time_to_happen = {
		days = 2
	}
	
	immediate = {
		#Clear core status
		225 = {
			remove_core_of = SSU
			remove_core_of = AGF
		}
		226 = {
			remove_core_of = SSU
			remove_core_of = AGF
		}
		227 = {
			remove_core_of = SSU
			remove_core_of = AGF
		}
		924 = {
			remove_core_of = SSU
			remove_core_of = AGF
		}
		923 = {
			remove_core_of = SSU
			remove_core_of = AGF
		}
		923 = {
			remove_claim_by = SSU
			remove_claim_by = AGF
		}
		925 = {
			remove_core_of = SSU
			remove_core_of = AGF
		}
		925 = {
			remove_claim_by = SSU
			remove_claim_by = AGF
		}
		926 = {
			remove_core_of = SSU
			remove_core_of = AGF
		}
		926 = {
			remove_claim_by = SSU
			remove_claim_by = AGF
		}
		927 = {
			remove_core_of = SSU
			remove_core_of = AGF
		}
		927 = {
			remove_claim_by = SSU
			remove_claim_by = AGF
		}
		SSU = {
			add_state_core = 225
			add_state_core = 226
			add_state_core = 227
			add_state_core = 924
			add_state_core = 923
			add_state_core = 925
			add_state_core = 926
			add_state_core = 927
			set_capital = 227
		}
	}
	
	option = {
		name = SouthSudan.1.a
		log = "[GetDateText]: [This.GetName]: SouthSudan.1.a executed"
	}
}

news_event = {

	id = SouthSudanNews.1
	title = SouthSudanNews.1.t
	desc = {
		text = SouthSudanNews.1.SSU.d
		trigger = { FROM = { original_tag = SSU } }
	}
	desc = {
		text = SouthSudanNews.1.AGF.d
		trigger = { FROM = { original_tag = AGF } }
	}
	picture = GFX_news_south_sudan_civil_war
	
	major = yes
	
	is_triggered_only = yes
	
	option = {
		name = SouthSudanNews.1.a
		log = "[GetDateText]: [This.GetName]: SouthSudanNews.1.a executed"
	}
	
}			